package com.study.dataStructure.hash;

import com.study.dataStructure.list.link.MyLinkedList;

/**
 * @author tiny
 * @date 2021/10/17 23:34
 * @Description:
 */
public class HashNumTable {

    private int size; //链表个数

    private MyLinkedList<Integer>[] links;

    public int hashCode(int num){
        return num%size;
    }

    public boolean add(int num){
        int index = hashCode(num);
        return links[index].add(num);
    }

    public int remove(int num){
        int index = hashCode(num);
        return links[index].remove(num);
    }

    public boolean contain(int num){
        int index = hashCode(num);
        return links[index].contain(num);
    }

    public void list(){
        int index = 0;
        for (MyLinkedList<Integer> link : links) {
            System.out.println("index: "+index+" - "+link.toString());
        }
    }

}
